<?php
require_once("include/auth.php");
require_once("include/db.php");

if ($_SERVER['REQUEST_METHOD'] !== "POST")
    die("Method not allowed.");

if (add_device($_SESSION['user_id'], $_POST['name'], $_POST['latitude'], $_POST['longitude'])) {
    header("HTTP/1.1 302 Moved Temporarily");
    header("Location: ./");
} else {
    die("Error adding device.");
}
